@import '../../style/themes/index';
@import '../../style/mixins/index';

@tag-prefix-cls: ~'@{ant-prefix}-tag';

.@{tag-prefix-cls} {
  .reset-component;

  display: inline-block;
  margin-right: 8px;
  font-size: @tag-font-size;
  white-space: nowrap;
  background: @tag-default-bg;
  border: @border-width-base @border-style-base @border-color-base;
  border-radius: @border-radius-base;
  cursor: default;
  opacity: 1;
  transition: all 0.3s @ease-in-out-circ;

  max-width: 120px;
  height: @tag-height;
  padding: 0 20px;
  line-height: @tag-height - 2px;
  text-align: center;
  border-radius: @tag-height / 2;
  text-overflow: ellipsis;
  overflow: hidden;
  vertical-align: middle;

  &.blue {
    background: rgba(47, 107, 255, 0.2);
    color: @primary-color;
    border-color: rgba(47, 107, 255, 0.2);
  }
  &.green {
    background: rgba(66, 197, 144, 0.3);
    color: @success-color;
    border-color: rgba(66, 197, 144, 0.3);
  }
  &.red {
    background: rgba(243, 94, 78, 0.2);
    color: @error-color;
    border-color: rgba(243, 94, 78, 0.2);
  }

  &.blueBorder {
    background: #fdfdfd;
    border-color: @primary-color;
    color: @primary-color;
  }
  &.greenBorder {
    background: #fdfdfd;
    border-color: @success-color;
    color: @success-color;
  }
  &.redBorder {
    background: #fdfdfd;
    border-color: @error-color;
    color: @error-color;
  }

  &:hover {
    opacity: 0.85;
  }

  &,
  a,
  a:hover {
    color: @tag-default-color;
  }

  > a:first-child:last-child {
    display: inline-block;
    margin: 0 -8px;
    padding: 0 8px;
  }

  .@{iconfont-css-prefix}-close {
    .iconfont-size-under-12px(10px);

    margin-left: 3px;
    color: @text-color-secondary;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s @ease-in-out-circ;

    &:hover {
      color: @heading-color;
    }
  }

  &-has-color {
    border-color: transparent;
    &,
    a,
    a:hover,
    .@{iconfont-css-prefix}-close,
    .@{iconfont-css-prefix}-close:hover {
      color: @text-color-inverse;
    }
  }

  &-checkable {
    background-color: transparent;
    border-color: transparent;
    &:not(&-checked):hover {
      color: @primary-color;
    }
    &:active,
    &-checked {
      color: @text-color-inverse;
    }
    &-checked {
      background-color: @primary-6;
    }
    &:active {
      background-color: @primary-7;
    }
  }

  &-hidden {
    display: none;
  }

  // mixin to iterate over colors and create CSS class for each one
  .make-color-classes(@i: length(@preset-colors)) when (@i > 0) {
    .make-color-classes(@i - 1);
    @color: extract(@preset-colors, @i);
    @lightColor: '@{color}-1';
    @lightBorderColor: '@{color}-3';
    @darkColor: '@{color}-6';
    &-@{color} {
      color: @@darkColor;
      background: @@lightColor;
      border-color: @@lightBorderColor;
    }
    &-@{color}-inverse {
      color: @text-color-inverse;
      background: @@darkColor;
      border-color: @@darkColor;
    }
  }

  .make-color-classes();
}
